require('dotenv').config()
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { AppModule } from './app.module';

async function bootstrap() {

  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  //接口跨越
  app.enableCors({
    origin: '*',
    credentials: true,
    methods: "PUT,POST,GET,DELETE,OPTIONS",
    exposedHeaders: "*"
  })

  //静态文件路径
  app.useStaticAssets("public", { prefix: "/web/public" })
  app.useStaticAssets("public", { prefix: "/web" })
  app.useStaticAssets("public", { prefix: "/public" })

  //添加验证管道
  app.useGlobalPipes(new ValidationPipe({
    disableErrorMessages: true,
  }));

  //信任代理 
  app.set('trust proxy', 1);


  //启动端口
  const port = process.env.PORT || 9080
  await app.listen(port);


}
bootstrap();
